/**
 * form表单
 */
seajs.use(["zui/form","zui/fightCalendar","zui/date"],function(Form,Calendar,zDate){
	var form1 = 
			new Form({srcNode:"#CM_Form",validType:"custom",validateFunc:function(ev){
				var field=ev.field;
				var msg=ev.validateMsg;
				if(msg==""){

				}else{
				  	App.showToast(msg);
			  	}
		  	}});
	$(".zaw-btn").on("click",function(){
		if(form1.valid()){
			$("#CM_Form").submit();
		}
	});
	//选择常用投保人
	$(".user-select").on("change",function(){
		alert("选择常用投保人");
	});
	//选择证件类型
	$(".certype-select").on("change",function(){
		var idType = $(this).val();
		if( idType == "1" || idType == "I" ){		//身份证=I
			$(this).parents(".form-box").find("#idCard").attr("data-rules","{required:true,isIdCard:'请输入正确证件号!'}");
			$(this).parents(".form-box").find("#idCard").attr("data-messages","{required:'请输入您的证件号码',isIdCard:'请输入正确证件号!'}");
			$(this).parents(".form-box").find(".form-date").attr("readonly","readonly");
		}else{
			$(this).parents(".form-box").find("#idCard").attr("data-rules","{required:true}");
			$(this).parents(".form-box").find("#idCard").attr("data-messages","{required:'请输入您的证件号码'}");
			$(this).parents(".form-box").find(".form-date").removeAttr("readonly");
		}
	});
	//选择常用投保人
	$(".contect-select").on("change",function(){
		var contectType = $(this).val();
		if( contectType == "1" || contectType == "1" ){		//本人=1
			$(this).parents(".form-box").find(".contect-room").hide();
		}else{
			$(this).parents(".form-box").find(".contect-room").show();
		}
	});

});